package com.xgq.drink.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xgq.drink.entity.AttributeProduct;
import com.xgq.drink.mapper.AttributeProductMapper;
import com.xgq.drink.service.IAttributeProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xgq
 * @since 2025-03-03
 */
@Service
public class AttributeProductServiceImpl extends ServiceImpl<AttributeProductMapper, AttributeProduct> implements IAttributeProductService {
    @Autowired
    private AttributeProductMapper attributeProductMapper;
    @Override
    public List<AttributeProduct> getAttributesByProduct(Long productId) {
        QueryWrapper<AttributeProduct> queryWrapper = new QueryWrapper<>();

        // 添加查询条件
        queryWrapper.eq("product_id", productId) // product_id等于传入的productId
                .ne("is_del", 1);            // is_del不等于1

        // 执行查询并返回结果
        return attributeProductMapper.selectList(queryWrapper);
    }

}
